package org.zpmis.domain.customer.vo;

import lombok.Data;
import org.zpmis.domain.customer.model.CustomerCarePlan;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class GetCustomerCarePlanDetailVo {
    /**
     * 主键id
     */
    private Long id;
    /**
     * 企业表id
     */
    private Long companyId;

    /**
     * 关怀对象 1 意向客户  2 企业客户
     */
    private Integer careObject;

    /**
     * 跟进人id
     */
    private Long chargePersonId;

    /**
     * 负责人、跟进人
     */
    private String chargePerson;

    /**
     * 企业名称
     */
    private String companyName;

    /**
     * 联系人
     */
    private String contactPerson;

    /**
     * 联系手机号
     */
    private String contactMobile;

    /**
     * 跟进计划描述
     */
    private String planDesc;

    /**
     * 关怀方式
     */
    private Integer careType;

    /**
     * 关怀日期
     */
    private String careTime;

    /**
     * 执行日期
     */
    private String executeTime;

    /**
     *执行计划结果
     */
    private String executeDesc;

    /**
     * 执行人id
     */
    private Long executeId;

    /**
     * 是否删除
     */
    private Integer isDeleted;

    /**
     * 回访状态 1进行中2已完结
     */
    private Integer status;

    /**
     * 是否提醒
     */
    private Integer isRemind;

    /**
     * 备注
     */
    private String remake;

    /**
     * 创建人id
     */
    private Long createId;

    /**
     * 创建人
     */
    private String createPerson;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 企业code
     */
    private String companyCode;


    public static GetCustomerCarePlanDetailVo toCustomerCarePlanDetailVo(CustomerCarePlan customerCarePlan) {
        if(customerCarePlan == null){
            return null;
        }
        GetCustomerCarePlanDetailVo planDetailVo = new GetCustomerCarePlanDetailVo();
        planDetailVo.setId(customerCarePlan.getId());
        planDetailVo.setCompanyId(customerCarePlan.getCompanyId());
        planDetailVo.setCareObject(customerCarePlan.getCareObject());
        planDetailVo.setChargePersonId(customerCarePlan.getChargePersonId());
        planDetailVo.setChargePerson(customerCarePlan.getChargePerson());
        planDetailVo.setCompanyName(customerCarePlan.getCompanyName());
        planDetailVo.setContactPerson(customerCarePlan.getContactPerson());
        planDetailVo.setContactMobile(customerCarePlan.getContactMobile());
        planDetailVo.setPlanDesc(customerCarePlan.getPlanDesc());
        planDetailVo.setCareType(customerCarePlan.getCareType());
        planDetailVo.setCareTime(customerCarePlan.getCareTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerCarePlan.getCareTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        planDetailVo.setExecuteDesc(customerCarePlan.getExecuteDesc());
        planDetailVo.setExecuteId(customerCarePlan.getExecuteId());
        planDetailVo.setExecuteTime(customerCarePlan.getExecuteTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerCarePlan.getExecuteTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        planDetailVo.setIsDeleted(customerCarePlan.getIsDeleted());
        planDetailVo.setStatus(customerCarePlan.getStatus());
        planDetailVo.setIsRemind(customerCarePlan.getIsRemind());
        planDetailVo.setRemake(customerCarePlan.getRemake());
        planDetailVo.setCreateId(customerCarePlan.getCreateId());
        planDetailVo.setCreatePerson(customerCarePlan.getCreatePerson());
        planDetailVo.setCreateTime(customerCarePlan.getCreateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerCarePlan.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));;
        planDetailVo.setCompanyCode(customerCarePlan.getCompanyCode());
        return planDetailVo;
    }
}
